@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/admin/pagenum.css')}}" rel="stylesheet" />
@endsection

@section('html-body')
        <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">当前位置：</span>
            <a href="">医生列表</a>
        </div>
        <!-- cur-position end -->

        <!-- filter-box start -->
        <div class="filter-box clearfix">
            <div class="fr">
                <a class="addBtn" href="{{route('Admin.Index.doctorAdd')}}">新增</a>
            </div>
        </div>
        <!-- filter-box end -->

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>医生</th>
                    <th>所在医院</th>
                    <th>主治科目</th>
                    <th>性别</th>
                    <th>岗位级别</th>
                    <th>预约数量</th>
                    <th>当前状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if($doctors && count($doctors)>0)
                    @foreach($doctors as $doctor)
                        <tr>
                            <td class="account-td imptc">
                                <span class="photo">
                                    <img src="{{route('Api.Image.Show',['id'=>$doctor->doc_img])}}" alt="">
                                 </span>
                                <div class="info-box">
                                    <p>
                                        <span class="name">{{$doctor->doc_name}}</span>
                                    </p>
                                </div>
                            </td>
                            <td>{{$doctor->hospital_name}}</td>
                            <td>{{$doctor->dep_name}}</td>
                            <td>@if((int)$doctor->sexual == 1)男 @else女 @endif</td>
                            <td>{{$doctor->station}}</td>
                            <td>{{$doctor->bespoke_count}}</td>
                            <td>@if((int)$doctor->is_work == 2)<span class="color3">不通过</span>@elseif((int)$doctor->is_work == 1)<span class="color4">正常</span>@else<span class="color2">待审核</span> @endif</td>
                            <td class="btna"><a href="{{route('Admin.Index.doctorDetail')}}?id={{$doctor->user_id}}">审核</a> | <a class="color1 add" href="{{route('Admin.Index.doctorAdd')}}?id={{$doctor->id}}">修改资料</a>
                                {{--| <a class="color5 del" href="javascript:void(0);" data-id="{{$doctor->id}}">删除</a>--}}
                            </td>
                        </tr>
                        @endforeach
                    @endif
                </tbody>
                <tfoot class="order-gl">
                </tfoot>
            </table>
        </div>
        <div>
            {!! $doctors->render() !!}
        </div>
    </div>
    <!-- content end -->
    <script>
        $(function() {
            jQuery.ajaxSetup({
                case: false,
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });

            $('.del').click(function () {
                var id = $(this).attr('data-id');
                $.ajax({
                    type: "post",
                    url: '{{route('Api.Admin.delDoctor')}}',
                    dataType: "json",
                    data: {'id': id},
                    success: function (obj) {
                        if (obj.level == "success") {
                            noty({
                                text: obj.message, type: obj.level, timeout: 800,
                                callback: {
                                    afterClose: function () {
                                        location.reload();
                                    }
                                }
                            });
                        }
                    },
                    error: function (obj) {
                        var datajson = obj.responseJSON;
                        noty({text: datajson.message, type: 'error', timeout: 600});
                    }
                });
            });
        });
    </script>
@endsection